/**
 * Created by mapbar_front on 2019/8/5.
 */
import React,{Component} from 'react';

function handleClick(ref){
    console.log('handleClick',ref.current); //<input type="text"/>
    ref.current.focus()
}
const Test = React.forwardRef((props,ref)=>{
    console.log('ref',ref.current); //null
    return <div>
                <input type="text" ref={ref} />
                <button onClick={()=>handleClick(ref)}>
                    {props.children}
                </button>
            </div>
})


class Ref3 extends Component{
    constructor(props){
        super(props);
        this.ref = React.createRef();
    }
    handleClick(){
        console.log('this.ref');
    }
    render(){
        return(
            <Test ref={this.ref}>
                点我
            </Test>
        )
    }
}
export default Ref3;
